package oot.data;

import oot.activity.FlashScreenActivity;

import android.util.Log;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class Connection {
	public static String accesstoken;
	
	public static final String BASE_URL = "http://192.168.1.8/";
	public static final String BASE_URL_IMAGE = "http://192.168.1.8";
	private static final String BASE_URL2 = "http://192.168.1.8/";

	  private static AsyncHttpClient client = new AsyncHttpClient();

	  public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
		  client.setTimeout(10000);
	      client.get(getAbsoluteUrl(url), params, responseHandler);
	  }

	  public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
		  
		  client.setTimeout(10000);
		  params.put(Config.ACCESSTOKEN, accesstoken);
		  params.put("userid", FlashScreenActivity.user.getUserID());
		  Log.e("PARAM","PARAM : " + params.toString());
	      client.post(getAbsoluteUrl(url), params, responseHandler);
	  }
	  public static void post2(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
		  params.put(Config.ACCESSTOKEN, accesstoken);
		 params.put("userid", FlashScreenActivity.user.getUserID());
	      client.post(getAbsoluteUrl2(url), params, responseHandler);
	  }

	  private static String getAbsoluteUrl(String relativeUrl) {
	      return BASE_URL + relativeUrl;
	  }
	  private static String getAbsoluteUrl2(String relativeUrl) {
	      return BASE_URL2 + relativeUrl;
	  }
}
